package a_baseExample1;

import java.io.File;
import java.util.HashMap;
import java.util.Map;

import org.apache.commons.io.FileUtils;

import com.alibaba.fastjson.JSON;
import com.wang.template.json.JsonLoader;
import com.wang.template.json.JsonRender;
import com.wang.template.json.node.BaseNode;

public class BaseExample {
	/**
	 * 数据源是map
	 * @param args
	 * @throws Exception
	 */
	public static void main(String[] args) throws Exception {
		Map<String, Object> dataSource = new HashMap<String, Object>();
		String jsonStr = FileUtils.readFileToString(new File(BaseExample.class.getResource("json.json").getPath()),"UTF-8");
		BaseNode node = JsonLoader.load(jsonStr);
		dataSource.put("retCode", "000000");
		dataSource.put("retMsg", "服务执行成功");
		long start = System.currentTimeMillis();
		Object obj = JsonRender.render(node, dataSource);
		System.out.println("耗时" + (System.currentTimeMillis() - start) + JSON.toJSONString(obj, true));
	}
}
